﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using EnvDTE;
using EnvDTE80;

namespace SinacorRules
{
    public sealed class Rule_BaseCommunication : BaseAddIn.Rules.BaseRuleAddIn
    {
        #region Campos

        private Type _tipoBaseCommunication;

        #endregion

        #region Construtor

        public Rule_BaseCommunication() :
            base("BaseCommunication", "SinacorRules.SinacorRules", typeof(Rule_BaseCommunication).Assembly)
        {
            _tipoBaseCommunication = typeof(Sinacor.Infra.UI.Common.BaseCommunication);
        }

        #endregion

        #region Protected Override Methods

        protected sealed override void Check(CodeClass2 classe)
        {
            if (classe.Namespace.Name.EndsWith(".Communication")
                && !Common.Rotinas.CheckClassInheritance(classe, _tipoBaseCommunication))
            {
                GeraProblemaAddIn(classe.StartPoint.Parent.Parent.FullName,
                                  classe.StartPoint.Line,
                                  classe.StartPoint.DisplayColumn,
                                  "BaseCommunicationResolution",
                                  classe.Name,
                                  classe.Namespace.Name);
            }
        }

        #endregion
    }
}
